package com.kl.controller;

import com.kl.em.ConstantEnum;
import com.kl.em.Result;
import com.kl.feign.FreightServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/linelogisticsstore")
@Api(value = "价格时效查询")
public class EvaluationController {
    @Autowired
    private FreightServiceFeign freightServiceFeign;

    @ApiOperation(value = "根据id和重量得出价格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "volume", value = "m³", required = true, paramType = "query"),
            @ApiImplicitParam(name = "kg", value = "kg", required = true, paramType = "query")
    })
    @GetMapping("/getPrices")
    public Result getPrice(@RequestParam Integer id,@RequestParam Integer volume,@RequestParam Integer kg) {
        Result price = freightServiceFeign.getPrice(id,volume,kg);
        Integer result = (Integer)price.getResult();
        return Result.build(ConstantEnum.SUCCESS).setResult(result);
    }
}
